<?php /*a:2:{s:72:"/www/wwwroot/cloud_boss/application/admin/view/equipment/add_qrcode.html";i:1598866872;s:64:"/www/wwwroot/cloud_boss/application/admin/view/public/basic.html";i:1573743224;}*/ ?>
<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <title><?php echo htmlentities((isset($title) && ($title !== '')?$title:'重庆优合一众')); ?></title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
    <meta name="apple-mobile-web-app-status-bar-style" content="black">
    <meta name="apple-mobile-web-app-capable" content="yes">
    <meta name="format-detection" content="telephone=no">
    <link rel="stylesheet" href="/static/plugs/layui/css/layui.css" media="all"/>
    <!--<link rel="stylesheet" href="/static/layuicms/css/index.css" media="all" />-->
    
</head>
<body class="<?php echo htmlentities((isset($body) && ($body !== '')?$body:'childrenBody')); ?>">

<link rel="stylesheet" href="/static/css/admin/public.css" media="all"/>

<form id="form" class="layui-form" style="width:80%;">
    <div class="layui-tab">
        <ul class="layui-tab-title">
            <li class="layui-this">基本信息</li>
        </ul>
        <div class="layui-tab-content ">
            <!--基本信息-->
            <div class="layui-tab-item layui-show">
                <div class="layui-form-item layui-row layui-col-xs12">
                    <label class="layui-form-label">生成方式</label>
                    <div class="layui-input-block type">
                        <input type="radio" name="type" value="1" title="单个" checked lay-filter="selectType">
                        <input type="radio" name="type" value="2" title="批量" lay-filter="selectType">
                    </div>
                </div>
                <div class="layui-form-item layui-row layui-col-xs12">
                    <label class="layui-form-label">所属公司</label>
                    <div class="layui-input-block region">
                        <select name="region" class="region">
                            <option value="YZ">华信</option>
                            <option value="YH">优合一众</option>
                        </select>
                    </div>
                </div>
                <div class="layui-form-item layui-row layui-col-xs12">
                    <label class="layui-form-label" id="lable"></label>
                    <div class="layui-input-block">
                        <input type="text" name="qrcode_no" class="layui-input qrcode_no" lay-verify="required" value="<?php echo htmlentities((isset($data['qrcode_no']) && ($data['qrcode_no'] !== '')?$data['qrcode_no']:'')); ?>" placeholder="请输入二维码编号/前缀">
                        <div style="color:red">二维码编号默认是8位数字，前缀默认是2位数字</div>
                    </div>
                </div>
                <div class="layui-form-item layui-row layui-col-xs12" id="num" hidden>
                    <label class="layui-form-label">数量</label>
                    <div class="layui-input-block">
                        <input type="text" name="num" class="layui-input num" lay-verify="required" value="<?php echo htmlentities((isset($data['num']) && ($data['num'] !== '')?$data['num']:'')); ?>" placeholder="请输入数量">
                    </div>
                </div>

                <input type="hidden" class="id" name="id" value="<?php echo htmlentities((isset($data['id']) && ($data['id'] !== '')?$data['id']:'')); ?>">
            </div>

        </div>
    </div>


    <div class="layui-form-item layui-row layui-col-xs12">
        <div class="layui-input-block">
            <button class="layui-btn layui-btn-sm" lay-submit="" id="addUser">确定</button>
            <button type="reset" class="layui-btn layui-btn-sm layui-btn-primary">取消</button>
        </div>
    </div>
    </div>
</form>


<script type="text/javascript" src="/static/plugs/jquery/jquery-2.2.4.min.js"></script>
<script type="text/javascript" src="/static/plugs/layui/layui.js"></script>
<script type="text/javascript" src="/static/admin.js"></script>
<script type="text/javascript" src="/static/js/admin/api.js"></script>

<script type="text/javascript" src="/static/layuicms/layui/layui.js"></script>
<script type="text/javascript" src="/static/plugs/webuploader.min.js"></script>

<script>

    layui.use(['form','layer','layedit','upload','element'],function(){
        var form = layui.form,
            layer = parent.layer === undefined ? layui.layer : top.layer,
            laypage = layui.laypage,
            upload = layui.upload,
            layedit = layui.layedit,
            element = layui.element,
            $ = layui.jquery;

        //一些事件监听
        element.on('tab(demo)', function (data) {
            console.log(data);
        });

        /**
         * 新增以及编辑后台用户
         */
        $("#addUser").click(function () {
            var url = '<?php echo url("$thisClass/add_qrcode"); ?>';
            var data = {
                id: $(".id").val(),
                qrcode_no: $(".qrcode_no").val(),
                type: $('input[name="type"]:checked').val(),
                region:$('.region option:selected').val(),
                num:$('.num').val(),
            };
            if(data.qrcode_no.length !=2 && data.qrcode_no.length !=8){
                layer.msg('二维码编号格式不正确!');
            }
            $.ajax({
                url: url,
                method:"POST",
                data: data,
                success:function(res){
                    if(res.code ==1){
                        layer.msg(res.msg,{icon: 1});
                        setTimeout(function(){
                            //刷新父页面
                            parent.location.reload();
                        },500);

                    }else{
                        layer.msg(res.msg);
                    }
                }
            });
            return false;
        });

        //初始化
        $('#num').hide();
        $('#lable').text('二维码编号/前缀');

        // 监听选择二维码生成类型
        form.on('radio(selectType)', function (data) {
            var value = data.value;
            if(value==1){
                $('#lable').text('二维码编号/前缀');
                $('#num').hide();//单个
            }else{
                $('#lable').text('前缀');
                $('#num').show();//批量
            }

        });

        form.render();

    });




</script>

</body>
</html>